try {
  let response,
    minLevel = 100,
    maxLevel = 0,
    objectArray = [],
    load = { datas: [] },
    continuity = false,
    textLoad = "";
  document.getElementsByClassName("api-title").forEach((item) => {
    if (item.innerText === "响应参数")
      response = item.nextSibling.getElementsByClassName("ant-table-row");
  });
  // 找到最大level
  response.forEach((item) => {
    if (item.className.split("").at(-1) > maxLevel)
      maxLevel = item.className.split("").at(-1);
    if (item.className.split("").at(-1) < minLevel)
      minLevel = item.className.split("").at(-1);
    objectArray.push({
      class: item.className.split("").at(-1),
      key: item.children[0].innerText,
      title: item.children[1].innerText,
      type: item.children[2].innerText,
    });
  });
  while (minLevel <= maxLevel) {
    for (let i = objectArray.length - 1; i >= 0; i--) {
      const item = objectArray[i];
      if (item.class != maxLevel) continuity = false;
      if (item.class == maxLevel) {
        if (load.datas.length == 0) load.end = i;
        continuity = true;
        load.datas.push(item);
      }
      if (load?.datas.length > 0 && !continuity) {
        load.start = i + 1;
        item.children = load.datas;
        generate(item, load);
        objectArray.splice(load.start, load.end - load.start + 1);
        load = { datas: [] };
      }
    }
    maxLevel--;
  }
  console.log(textLoad);
  function generate(item, load) {
    let temp = `interface ${capitalizeFirstLetter(item.key)}Model { \n`;
    load.datas.forEach((value) => {
      let type = value.type;
      let tempType = "";
      if (type.indexOf("integer") >= 0) tempType = "number";
      else if (type.indexOf("string") >= 0) tempType = "string";
      else if (type.indexOf("boolean") >= 0) tempType = "boolean";
      else if (type.indexOf("array") >= 0)
        tempType = `${capitalizeFirstLetter(value.key)}[]`;
      else tempType = "any";
      temp += `\t${value.key}: ${tempType}; // ${value.title} \n`;
    });

    temp += "}\n";
    textLoad = temp + textLoad;
  }
  function capitalizeFirstLetter(string) {
    return string.charAt(0).toUpperCase() + string.slice(1);
  }
} catch (error) {
  console.error(error);
}
